<?php
 
/*
 * Following code will list all the products
 */
 
// array for JSON response
$response = array();

 // check for required fields
if (isset($_GET['user_id_zing'])){
	$user_id_zing = $_GET['user_id_zing']; 
	
	
	// include db connect class
	require_once __DIR__ . '/db_connect.php';
	 
	// connecting to db
	$db = new DB_CONNECT();
	 
	// get all products from products table

	$result = mysql_query("SELECT * FROM user WHERE 'delete' = 0 AND user_id_zing = '$user_id_zing'") or die(mysql_error());
							
	 
	// check for empty result
	if (mysql_num_rows($result) > 0) {
		// looping through all results
		// products node
		$response["user"] = array();
	 
		while ($row = mysql_fetch_array($result)) {
			// temp user array
			$user = array();    
		
			$user["user_id"] = $row['user_id'];
			$user["user_id_zing"] = $row['user_id_zing'];
			$user["user_name_zing"] = $row['user_name_zing'];
			$user["user_display_name"] = $row['user_display_name'];
			$user["user_avatar_zing"] = $row['user_avatar_zing'];
		 
			// push single product into final response array
			array_push($response["user"], $user);
		}
		// success
		$response["success"] = 1;
	 
		// echoing JSON response
		echo json_encode($response);
	} else {
		// no products found
		$response["success"] = 0;
		$response["message"] = "No products found";
	 
		// echo no users JSON
		echo json_encode($response);
	}
} else {
    // required field is missing
    $response["success"] = 0;
    $response["message"] = "Required field(s) is missing";
 
    // echoing JSON response
    echo json_encode($response);
}

?>